<template>
  <div class="login">
    <div class="con">
      <h3 class="text-center h3">登录</h3>
      <el-input v-model="user.username" clearable placeholder="请输入用户名"></el-input>
      <el-input
        v-model="user.password"
        clearable
        show-password
        placeholder="请输入密码"
      ></el-input>
      <div class="text-center">
        <el-button type="primary" @click="login">登录</el-button>
      </div>
    </div>
  </div>
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import { requserlogin } from '../../http/api';
import { successAlert } from '../../utils/alert';
export default {
  data() {
    return {
      user:{
        username:"",
        password:""
      }
    };
  },
  computed: {
    ...mapGetters({}),
  },
  mounted() {},
  methods: {
    ...mapActions({
      changeInfo:"changeInfo"
    }),
    login(){
      requserlogin(this.user).then(res=>{
        if(res.data.code===200){
          successAlert(res.data.msg);
          this.changeInfo(res.data.list);
          this.$router.push('/');
        }
      })
    }
  },
};
</script>
<style scoped lang="less">
@import "../../less/index.less";
.login{
  width: 100vw;
  height: 100vh;
  background: linear-gradient(to right,@primary-light,@primary-deep);
  position: relative;
  .con{
    position: absolute;
    width: 380px;
    padding:@padding20;
    background: #fff;
    border-radius: @padding10;
    left: 50%;
    top:50%;
    transform: translate(-50%,-50%);
    .el-input{
      margin-bottom: @margin20;
    }
  }
}
</style>